local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, CommonOHOH.files.BaseComponent());
local CallBackManager = CommonOHOH.load.CallBackManager();

function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);
	self.car=self.parent
	self.player=self.parent.player
	self.isPlayer = self.parent.isPlayer

	self:Init()
	

	self:UpdateSpeed()
end;

function M.Init(self)
	if self.isPlayer then
		self.CarInfoCtrl=self.player:GetComponent(_G.CommonOHOH.load.Common_CarInfoCtrl())
		CallBackManager:AddRbxConnect(self,self.CarInfoCtrl.UpdateEvent, function()
			self:UpdateSpeed()
		end);
	end
end
--更新前进速度
function M.UpdateSpeed(self)
	--推进力
	if self.isPlayer then
		local propulsion=self.CarInfoCtrl:GetPropulsion()
		-- self.car:SetForwardSpeed(propulsion)
		-- print("self.car",self.car)
		local carDirect = self.car:GetForwardUnit()
		carDirect = Vector3.new(carDirect.X, -20, carDirect.Z)
		self.car:SetForwardSpeed(4,carDirect)
	else
		-- print("self.car",self.car)
		local carDirect = self.car:GetForwardUnit()
		carDirect = Vector3.new(carDirect.X, -20, carDirect.Z)
		self.car:SetForwardSpeed(4,carDirect)
	end

end


function M.dtor(self)
	M.super.dtor(self);
end


return M